#pragma once
#include <iostream>
#include "RBtree.hpp"

namespace me
{
    template <typename K>
    class set
    {
        struct K2V
        {
            const K& operator()(const K& other) const
            {
                return other;
            }
        };

        using rbt = rbtree<K, const K, K2V>;
        using iterator = typename rbtree<K, const K, K2V>::iterator; // 之所以传constk过去，是因为set不论是普通迭代器还是const迭代器都无法修改key值
        using const_iterator = typename rbtree<K, const K, K2V>::const_iterator;
    public:
        std::pair<iterator, bool> insert (const K& key)
        {
            return _tree.insert(key);
        }

        iterator begin() { return _tree.begin(); }
        const_iterator begin() const { return _tree.begin(); }
        const_iterator cbegin() const { return _tree.cbegin(); }

        iterator end() { return _tree.end(); }
        const_iterator end() const { return _tree.end(); }
        const_iterator cend() const { return _tree.cend(); }
    private:
        rbt _tree;
    };
}